#include "mainmenu.h"
#include "ui_mainmenu.h"
#include <QPainter>
#include <QTimer>
#include <QMessageBox>

MainMenu::MainMenu(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainMenu)
{
    ui->setupUi(this);
    //    设置固定大小
    //    设置标题
    setWindowTitle("CTYYPE");
    setFixedSize(1280,720);
    //    设置图标
   setWindowIcon(QIcon(":/image/enemy1.png"));
    //    设置按钮
    startBTN= new picButton(0.6,":/image/SHQico.png");
    startBTN->setParent(this);
    startBTN->move(765,200);
    startBTN->setShadow();

    connect(startBTN,&picButton::clicked,[=](){
        //           qDebug()<<"点击开始";
        startBTN->zoom1();
        startBTN->zoom2();

        QTimer::singleShot(200,this,[=](){
            gseting =new GameSeting();
            gseting->show();

        });
    });

    helpBTN= new picButton(0.6,":/image/SHQico.png");
    helpBTN->setParent(this);
    helpBTN->move(765,300);
    helpBTN->setShadow();

    connect(helpBTN,&picButton::clicked,[=](){
        //           qDebug()<<"点击开始";
        helpBTN->zoom1();
        helpBTN->zoom2();
        help = new HelpUI();
        help->show();
    });

    quitBTN= new picButton(0.6,":/image/SHQico.png");
    quitBTN->setParent(this);
    quitBTN->move(765,400);
    quitBTN->setShadow();

    connect(quitBTN,&picButton::clicked,[=](){
        //           qDebug()<<"点击开始";
        quitBTN->zoom1();
        quitBTN->zoom2();
        this->close();
    });
}

void MainMenu::paintEvent(QPaintEvent *event)
{
    QPainter resPainter(this);
    resPainter.drawPixmap(0,0,this->width(),this->height(),QPixmap(":/image/menu.jpg"));
    //添加图标
    QPixmap pix1;
    pix1.load(":/image/Sico.png");
    pix1=pix1.scaled(pix1.width()*0.6,pix1.height()*0.6);
    resPainter.drawPixmap(518,200,pix1);
    //添加图标
    QPixmap pix2;
    pix2.load(":/image/Hico.png");
    pix2=pix2.scaled(pix2.width()*0.6,pix2.height()*0.6);
    resPainter.drawPixmap(518,300,pix2);
    //添加图标
    QPixmap pix3;
    pix3.load(":/image/Qico.png");
    pix3=pix3.scaled(pix3.width()*0.6,pix3.height()*0.6);
    resPainter.drawPixmap(518,400,pix3);

}


MainMenu::~MainMenu()
{
    delete startBTN;
    delete helpBTN;
    delete quitBTN;
    delete ui;
}
